<?php


namespace app\api\validate;


use app\common\validate\BaseValidate;

class UserAddressValidate extends BaseValidate
{
    protected $rule = [
        'id' => 'require',
        'contact' => 'require',
        'mobile' => 'require|mobile',
        'province_id' => 'require',
        'city_id' => 'require',
        'district_id' => 'require',
        'is_default' => 'in:0,1',
    ];


    protected $message = [
        'id.require' => '参数错误',
        'contact.require' => '请输入联系人',
        'mobile.require' => '请输入手机号码',
        'mobile.mobile' => '手机号码格式不正确',
        'province_id.require' => '请选择省',
        'city_id.require' => '请选择市',
        'district_id.require' => '请选择区',
        'is_default.in' => '设为默认项的取值范围是[0,1]',
    ];


    public function sceneAdd()
    {
        return $this->only(['contact','mobile','province_id','city_id','district_id','is_default']);
    }

    public function sceneEdit()
    {
        return $this->only(['id','contact','mobile','province_id','city_id','district_id','is_default']);
    }
}